package com.dsbj.mp.icardservice.feign.callback;


import com.dsbj.common.msg.ResponseMessage;
import com.dsbj.mp.icardservice.feign.WxApiFeign;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 * @author lvdong
 * @date 2017/11/29
 */
@Component
public class WxApiFeignCallback implements FallbackFactory<WxApiFeign> {
    private Logger logger = LoggerFactory.getLogger(WxApiFeignCallback.class);


    @Override
    public WxApiFeign create(Throwable throwable) {
        return new WxApiFeign() {
            @Override
            public ResponseMessage<String> getOpenIdByCode(String code) {
                logger.error("方法：getOpenIdByCode，参数type：{}", code);
                logger.error("调用WxApi服务getOpenIdByCode异常", throwable);
                return ResponseMessage.error("调用WxApi服务getOpenIdByCode异常");
            }
        };
    }
}
